package com.example.leetcode.tree;

import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

import java.util.List;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution144 {
    public List<Integer> preorderTraversal(TreeNode root) {
        return TreeUtils.preorderTraversal(root);
    }
}

public class leetcode144 {
    public static void main(String[] args) {
        Solution144 solution144 = new Solution144();
        Integer[] nums = {1,null,2,3};
        Integer[] nums1 = {};
        Integer[] nums2 = {1};
        Integer[] nums3 = {1,2};
        Integer[] nums4 = {1,null,2};
        test144(solution144, nums);
        test144(solution144, nums1);
        test144(solution144, nums2);
        test144(solution144, nums3);
        test144(solution144, nums4);
    }

    private static void test144(Solution144 solution144, Integer[] nums) {
        TreeNode root = TreeUtils.generateLeetcodeTree(nums);
        System.out.println(solution144.preorderTraversal(root));
    }
}
